//
//  HomePageCell2.m
//  Mtime2.0
//
//  Created by 凉气的Mac on 16/9/4.
//  Copyright © 2016年 凉气的Mac. All rights reserved.
//

#import "HomePageCell2.h"

#import "MtimeButton.h"

#import "HomePageCellView.h"

@implementation HomePageCell2


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self setupUI];
        
    }

    return self;
}

#pragma mark --
#pragma mark --设置界面
-(void)setupUI{

    [self setupTopView];
    
    [self setupCenterView];

}

-(void)setupTopView{

    UIButton *titleBtn = [[UIButton alloc]init];
    
    [titleBtn setTitle:@"电影商城" forState:UIControlStateNormal];
    
    [titleBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    titleBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 280);
    
    [self.contentView addSubview:titleBtn];
    
    [titleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.trailing.leading.equalTo(self.contentView);
        
        make.height.equalTo(@40);
        
    }];
    
    MtimeButton *rightBtn = [[MtimeButton alloc]init];
    
    [rightBtn setTitle:@"全部商品" forState:UIControlStateNormal];
    
    [rightBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    
    [rightBtn setImage:[UIImage imageNamed:@"homePage_poster_jiantou"] forState:UIControlStateNormal];
    
    [titleBtn addSubview:rightBtn];
    
    [rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.equalTo(titleBtn);
        
        make.right.equalTo(self.contentView).offset(-10);
        
    }];
    
    [self horizontalLineWithView:titleBtn andType:1];
    

}

-(void)setupCenterView{

    //左上的view
    HomePageCellView *view1 = [[HomePageCellView alloc]init];
    
    view1.titleLable.text = @"闪购专区";
    
    view1.titleLable.textColor = [UIColor orangeColor];

    view1.textLable.text = @"精选好货 每日更新";
    
    view1.picture.image = [UIImage imageNamed:@"手办4"];
    
    [self.contentView addSubview:view1];
    
    [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.contentView).offset(40);
        
        make.leading.equalTo(self.contentView);
        
        make.width.equalTo(@120);
        
        make.height.equalTo(@170);
        
        make.bottom.equalTo(self.contentView).offset(-100);
        
    }];
    
    [self verticalLineWithView:view1 andType:1];
    
    HomePageCellView *view2 = [[HomePageCellView alloc]init];
    
    view2.titleLable.text = @"新人专场";
    
    view2.titleLable.textColor = [UIColor redColor];
    
    view2.textLable.text = @"首单满199减150";
    
    view2.textLable.textColor = [UIColor redColor];
    
    view2.picture.image = [UIImage imageNamed:@"手办4"];
    
    [self.contentView addSubview:view2];
    
    [view2 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(view1.mas_right);
        
        make.right.equalTo(self.contentView);
        
        make.top.equalTo(view1).offset(1);
        
        make.height.equalTo(view1).multipliedBy(0.4);
        
    }];
    
    [view2.picture mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.left.equalTo(view2);
        
        make.width.equalTo(@80);
        
    }];
    
    [view2.titleLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(view2.picture.mas_right).offset(10);
        
        make.top.equalTo(view2).offset(10);
        
        make.height.equalTo(@21);
        
        make.width.equalTo(view2).offset(-80);
    
        
    }];
    
    [view2.textLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(view2.titleLable);
        
        make.top.equalTo(view2.titleLable.mas_bottom);
        
        make.height.equalTo(@20);
    
        make.width.equalTo(@100);
        
    }];
    
    [self horizontalLineWithView:view2 andType:1];
    
    HomePageCellView *view3 = [[HomePageCellView alloc]init];
    
    view3.titleLable.text = @"悠哉生活";
    
    view3.titleLable.textColor = [UIColor orangeColor];
    
    view3.textLable.text = @"轻松熊人气周边";
    
    view3.picture.image = [UIImage imageNamed:@"手办0"];
    
    [self.contentView addSubview:view3];
    
    [view3 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(view2.mas_bottom).offset(1);
        
        make.left.equalTo(view1.mas_right);
        
        make.bottom.equalTo(view1);
        
        make.width.equalTo(view2).multipliedBy(0.5);
        
    }];
    
    [self verticalLineWithView:view3 andType:1];
    
    
    HomePageCellView *view4 = [[HomePageCellView alloc]init];
    
    view4.titleLable.text = @"全场39元";
    
    view4.titleLable.textColor = [UIColor colorWithRed:0.400 green:0.400 blue:1.000 alpha:1.000];
    
    view4.textLable.text = @"手办折扣专区";
    
    view4.picture.image = [UIImage imageNamed:@"手办0"];
    
    [self.contentView addSubview:view4];
    
    [view4 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(view2.mas_bottom).offset(1);
        
        make.left.equalTo(view3.mas_right);
        
        make.bottom.equalTo(view1);
        
        make.width.equalTo(view2).multipliedBy(0.5);
        
    }];
    
    
    
    HomePageCellView *view5 = [[HomePageCellView alloc]init];
    
    view5.titleLable.text = @"特别策划";
    
    view5.titleLable.textColor = [UIColor cyanColor];
    
    view5.textLable.text = @"手办明星专区";
    
    view5.picture.image = [UIImage imageNamed:@"手办0"];
    
    [self.contentView addSubview:view5];
    
    [view5 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(view1.mas_bottom).offset(1);
        
        make.left.equalTo(self.contentView);
        
        make.bottom.equalTo(self.contentView);
        
        make.width.equalTo(view1);
        
    }];
    
    [self horizontalLineWithView:view5 andType:0];
    
    HomePageCellView *view6 = [[HomePageCellView alloc]init];
    
    view6.titleLable.text = @"好物推荐";
    
    view6.titleLable.textColor = [UIColor redColor];
    
    view6.textLable.text = @"吃土也要入手";
    
    view6.picture.image = [UIImage imageNamed:@"手办0"];
    
    [view6 bringSubviewToFront:view6.textLable];
    
    [view6 bringSubviewToFront:view6.titleLable];
    
    [self.contentView addSubview:view6];
    
    [view6 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(view1.mas_bottom).offset(1);
        
        make.left.equalTo(view5.mas_right);
        
        make.bottom.equalTo(self.contentView);
        
        make.width.equalTo(view3).multipliedBy(2);
        
    }];
    
    [view6.picture mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.right.bottom.equalTo(view6);
        
        make.left.equalTo(view6).offset(50);
    }];

    [self verticalLineWithView:view6 andType:0];
    
    [self horizontalLineWithView:view6 andType:0];
    
    
}



#pragma mark --
#pragma mark --线
//水平线
-(void)horizontalLineWithView:(UIView *)tempView andType:(NSInteger)type{

    UIView *lineView = [[UIView alloc]init];
    
    lineView.backgroundColor = [UIColor colorWithWhite:0.800 alpha:1.000];
    
    [self.contentView addSubview:lineView];
    
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(type == 0 ? tempView.mas_top : tempView.mas_bottom);
        
        make.width.equalTo(tempView);
        
        make.height.equalTo(@0.5);
        
        make.left.equalTo(tempView);
        
    }];
    
}

//垂直线
-(void)verticalLineWithView:(UIView *)tempView andType:(NSInteger)type{
    
    UIView *lineView = [[UIView alloc]init];
    
    lineView.backgroundColor = [UIColor colorWithWhite:0.800 alpha:1.000];
    
    [self.contentView addSubview:lineView];
    
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(type == 0 ? tempView.mas_left : tempView.mas_right);
        
        make.width.equalTo(@0.5);
        
        make.top.height.equalTo(tempView);
        
    }];
    
}



@end

































































